import request from "@/utils/request";

// 查询角色列表
export function queryRoleList(size, count) {
  const data = {
    pageSize: size,
    pageCount: count,
  };
  return request({
    url: "/auth/role/list",
    method: "post",
    data: data,
  });
}
// 根据orgid查询机构下所有角色列表
export function queryRolesByOrgId(id) {
  return request({
    url: "/auth/role/queryRolesByOrgId/" + id,
    method: "post",
  });
}
//编辑角色
export function modify(id, orgId, name, text) {
  const data = {
    id: id,
    orgId: orgId,
    name: name,
    descStr: text,
  };
  return request({
    url: "/auth/role/modify",
    method: "post",
    data: data,
  });
}
//添加角色
export function addRole(id, orgId, name, text) {
  const data = {
    id: id,
    orgId: orgId,
    name: name,
    descStr: text,
  };
  return request({
    url: "/auth/role/addRole",
    method: "post",
    data: data,
  });
}
//删除角色
export function delRole(id) {
  return request({
    url: "/auth/role/delRole/" + id,
    method: "post",
  });
}
//查看角色详情
export function getDetail(id) {
  return request({
    url: "/auth/role/detail/" + id,
    method: "post",
  });
}
//编辑账户角色
export function modifyAccountRoles(data) {
  return request({
    url: "/auth/accountRole/modifyAccountRoles",
    method: "post",
    data: data,
  });
}
//根据账户ID查询已选角色列表
export function listByAccId(id) {
  return request({
    url: "/auth/accountRole/listByAccId/" + id,
    method: "post",
  });
}
//设置账户角色(批量)
export function addAccountRoles(data) {
  return request({
    url: "/auth/accountRole/addAccountRoles",
    method: "post",
    data: data,
  });
}
//权限操作相关
//权限设置
export function setPermis(id) {
  return request({
    url: "/auth/permission/setPermis/" + id,
    method: "post",
  });
}
//权限保存
export function savePermis(data) {
  return request({
    url: "/auth/permission/savePermis",
    method: "post",
    data: data,
  });
}

//账户列表
export function accountList(data) {
  return request({
    url: "/auth/account/list",
    method: "post",
    data: data,
  });
}

//添加账户
export function addAccount(data) {
  return request({
    url: "/auth/account/add",
    method: "post",
    data: data,
  });
}

//编辑账户
export function modifyAccount(data) {
  return request({
    url: "/auth/account/modify",
    method: "post",
    data: data,
  });
}

//修改账户状态
export function editAccount(id, state) {
  return request({
    url: `/auth/account/${id}/state/${state}`,
    method: "post",
  });
}

//根据账户ID 查询所属机构列表
export function getAcconutList(id) {
  return request({
    url: `/auth/account/orgList/${id}`,
    method: "post",
  });
}

//删除账户
export function delAccount(id) {
  return request({
    url: `/auth/account/delAccount/${id}`,
    method: "delete",
  });
}

//

//删除账户角色
export function delAccountRole(id) {
  return request({
    url: `/auth/accountRole/delAccountRole/${id}`,
    method: "post",
  });
}
